<template>
  <button :class="{ [$style['controller-button']]: true }" class="flc">
    <div :class="{ [$style['controller-button-content']]: true, [$style['controller-back']]: isBack }" class="flc">
      <img :src="viewStatus" :class="$style['controller-button-icon']">
    </div>
    <div :class="$style['controller-button-border']"></div>
    <div :class="{ [$style['controller-button-bg']]: true, [$style['controller-back-bg']]: isBack }"></div>
  </button>
</template>

<script
  lang="ts"
  setup
  name="ControllerButton"
>
interface Props {
  names: Array<string>
  status: boolean
  isBack?: boolean
}

const props = withDefaults(defineProps<Props>(), {
  names: () => ['', ''],
  status: false,
  isBack: false
})

const viewStatus = computed(() => {
  return new URL(`/src/assets/white-theme/images/h5/controller/${props.names[Number(props.status)]}.png`, import.meta.url).href
})

</script>

<style
  module
  lang="scss"
>
.controller-button {
  @apply relative z-1;
  width: 55px;
  height: 55px;
  min-width: 55px;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;

  .controller-button-bg {
    @apply absolute z-0;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    transition: transform 0.3s;
  }

  .controller-back-bg {
    box-shadow: 2px 4px 18px 0px rgba(40, 94, 174, 0.3);
  }

  .controller-button-border {
    @apply absolute z-1 w-full h-full;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    transition: transform 0.3s;
  }

  .controller-button-content {
    @apply relative z-2;
    width: 42px;
    height: 42px;
    background: linear-gradient(180deg, #F1F8FF 0%, #C8DEF6 100%);
    box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.10), inset 2px 3px 4px 0px rgba(255, 187, 187, 0.12), inset -1px -2px 6px 0px rgba(138, 56, 188, 0.12);
    border: 1px solid rgba(194, 212, 234, 1);
    border-radius: 50%;
  }

  .controller-back {
    background: linear-gradient(171deg, #F1F8FF 0%, #B2CEEE 100%);
    box-shadow: 2px 2px 6px 0px rgba(12, 36, 72, 0.25), inset 4px 6px 16px 0px rgba(253, 255, 154, 0.12), inset -2px -4px 24px 0px rgba(56, 77, 188, 0.12);
  }

  .controller-button-icon {
    width: 28px;
    height: 28px;
  }

  @keyframes wave-play {
    from {
      transform: scale(0.8);
      opacity: 0;
    }

    50% {
      transform: scale(1);
      opacity: 1;
    }

    to {
      transform: scale(1.5);
      opacity: 0;
    }
  }

  &:active {
    .controller-button-content {
      background: linear-gradient(rgba(50, 123, 232, 0.2), rgba(50, 123, 232, 0.2)), linear-gradient(180deg, rgba(241, 248, 255, 1) 0%, rgba(200, 222, 246, 1) 100%);
      border-color: rgba(70, 115, 238, 1);
    }

    .controller-button-bg {
      transform: scale(0.8);
    }

    .controller-button-border {
      transform: scale(0.8);
    }
  }
}
</style>
